#实现将图片文件的内容转换base64的字符串

import base64  #导入base64模块

with open('images/plastic62.jpg','rb') as f:
    data = f.read()  #返回字节类型
    # print(type(data))
    print(data)
    myencode = base64.b64encode(data) #返回base64字节编码
    # print(type(myencode))
    print(myencode)

    encodestr = str(myencode,encoding='utf-8') #字节转换字符串
    print(type(encodestr))
    print(encodestr)